const api = require("../config/api");

function request(method, url, data) {
	console.log(api.url,'------------------');
	return new Promise((resolve, reject) => {
		let header = {
			// 'content-type': 'application/json',
			'content-type': 'application/x-www-form-urlencoded',
			'xcx-token': api.appid,
			'token': wx.getStorageSync("token")
		};
		wx.request({
			url: api.url+url,
			method: method,
			data: data,
			header: header,

			success: res => {
				resolve(res);
			},
			fail: err => {
				reject(err)
			}
		});
	})
}

module.exports = {
	request: request
}